<?php
session_start();
global $title;
require_once('db.php');
$title = msg('Add a Record');

/*
if(isset($_GET['sitepw'])) $_SESSION['sitepw'] = $_GET['sitepw'];
if(!isset($_SESSION['sitepw'])) $_SESSION['sitepw'] = 'wrongpw';

if($_SESSION['sitepw'] != 'volunteerforhaiti') {
	echo 'Sorry, you need proper credentials to access this form. <a href="http://4636.ushahidi.com">Go Back</a>.';
	die();
}
*/

if(!isset($_SESSION['wronglang'])) $_SESSION['wronglang'] = array();
if(isset($_GET['wronglang'])) {
	$skipid = (int)$_GET['wronglang'];
	$_SESSION['wronglang'][] = $skipid;
	//set_sms_status($skipid,0);
}



// Making sure that the "data_entry" variable is in the URL to allow/disallow showing the data entry fields
$showDataEntryFields = false;
if(isset($_GET["data_entry"]) && $_GET["data_entry"] == 1)
	$showDataEntryFields = true;
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include('header.php') ?>
	<?php include_once("sidebar.php"); ?>
	<div id="content" style="background-color:#fff;width: 1010px; text-wrap:unrestricted;">
	<div style="display:inline; float:left;background-color:#eeeeee;width:500px;">
	<div style="width:400px;margin-right:30px; ">
	
				<?php
			//	print_r($_GET);
				
				if(isset($_GET['success'])){
				    if($_GET['success'] == 0){ echo '<em>We put the last entry back in the queue. Here is another, keep on going!</em>';}
				
				    if($_GET['success'] == 2){ echo '<em>We made a note that you put the last entry in google. Here is another, keep on going!</em>';}
				    
				    if($_GET['success'] == 3){ echo '<em>We made a note that the last entry was already in google. Here is another, keep on going!</em>';}
				    
                    if($_GET['success'] == 4){ echo '<em>We took the last entry out of the queue. Here is another, keep on going!</em>';}
				}
				
			?>
			<form method="post" action="insert_post.php" enctype="multipart/form-data">
			<table width="400px" cellspacing=0>
				<?php 
				if(isset($_GET['sms'])){
				$grab_specific_sms = 0;
				if(isset($_GET['sneaksms'])) {
					$grab_specific_sms = $_GET['sneaksms'];
					?>
					<input type="hidden" id="sneaksms" name="sneaksms" value="<?php echo $_GET['sneaksms']; ?>" />
					<?php
				}
				$sms_message = get_available_sms($grab_specific_sms,$_SESSION['wronglang']);
				if($sms_message != false){
				?>
					<tr>
						<td colspan="2"><h3 style="color:#FF0000">You have 5 minutes to complete this form.<br/>
						Please <a href="http://wiki.ushahidi.com/doku.php?id=4636instructions">read the instructions</a> before you begin.</h3>
						
						
							<input type="hidden" id="cnnid" name="cnnid" value="<?php echo $sms_message['id']; ?>" /></td>
					</tr>
					
			
					
					<!--
					<tr>
						<td colspan="2">
							<?php echo $sms_message['id']; ?>
						
						</td>
						
					</tr>
		-->
		
		
		<?php if($sms_message['website_id'] == 2){ ?>
					
				<tr>
							<td colspan="2">
							<h3>Message Title: </h3>&nbsp;<?php echo htmlentities($sms_message['title']); ?>
						
						</td>
						</tr>
						
					<tr>
							<td colspan="2">
							<h3>Message Content: </h3><?php echo htmlentities($sms_message['original_text']); ?>
						
						</td>
						</tr>
						
							<?php if($sms_message['city'] != ''){ ?>
						
					<tr>
							<td colspan="2">
							<h3>City: </h3><?php echo $sms_message['city']; ?>
					
						</td>
					</tr>
					
					
					<?php } ?>
					
					
					
						<tr>		<td colspan="2">
							<h3>Url of Original Record: </h3><?php echo $sms_message['url']; ?>
							
						</td>
						</tr>
					
					<tr>
							<td colspan="2">
							<h3>Original Posting Date: </h3><?php echo preg_replace("/\d\d:\d\d:\d\d/","",$sms_message['date_retrieved']); ?>
						
						</td>
							
						</tr>
						
							<tr>
							<td colspan="2">
							<h3>Original Site Name: </h3>koneksyon.com
						
						</td>
					</tr>
					
					
						<?php }elseif($sms_message['website_id'] == 5){ ?>
				
		
					<tr>
							<td colspan="2">
							<h3>Message Title: </h3><?php echo $sms_message['title']; ?>
						
						</td>
						</tr>
						
					<tr>
							<td colspan="2">
							<h3>Message Content: </h3><?php echo preg_replace("/\%\%\%/","<br>",$sms_message['original_text']); ?>
						
						</td>
						</tr>
						
						
						<tr>
							<td colspan="2">
							<h3>Seeker Name: </h3><?php echo $sms_message['contact_name']; ?>
						
						</td>
						</tr>
						
						
							
				<tr>
							<td colspan="2">
							<h3>Photo Url: </h3><?php echo $sms_message['picture_url']; ?>
					
						</td>
					</tr>
					
					
					
						<tr>		<td colspan="2">
							<h3>Url of Original Record: </h3><?php echo $sms_message['url']; ?>
							
						</td>
						</tr>
					
					<tr>
							<td colspan="2">
							<h3>Original Posting Date: </h3>&nbsp;<?php echo preg_replace("/\d\d:\d\d:\d\d/","",$sms_message['date_retrieved']); ?>
						
						</td>
							
						</tr>
						
							<tr>
							<td colspan="2">
							<h3>Original Site Name: </h3>cbc.ca
						
						</td>
					</tr>
					


                <?php  }elseif($sms_message['website_id'] == 9){ ?>
				
				
			
		
		
		            	<tr>
							<td colspan="2">
							<h3 style="color:#FF0000">The following is information that came from an SMS text message in Haiti. It was translated by a translator and any actionable information that needed to get back to the ground fast has been completed. Your job is to enter any missing or found people described in the text message into the google people finder. As well, please put the use the cellphone number here as the call back number in the contact section.</h3>
						
						</td>
						</tr>
						
					
					<?php if($sms_message['first_name'] != ''){ ?>
					
					<tr>
							<td colspan="2">
							<h3>Given Name: </h3><?php echo $sms_message['first_name']; ?>
						
						</td>
						</tr>
					
					<?php } ?>
					
					<?php if($sms_message['last_name'] != ''){ ?>
					
					<tr>
							<td colspan="2">
							<h3>Family Name: </h3><?php echo $sms_message['last_name']; ?>
						
						</td>
						</tr>
					
					<?php } ?>
					
					<?php if($sms_message['sex'] != ''){ ?>
					
					<tr>
							<td colspan="2">
							<h3>Gender: </h3><?php echo $sms_message['sex']; ?>
						
						</td>
						</tr>
					
					<?php } ?>
					
					<?php if($sms_message['missingstatus'] != ''){ ?>
					
					<tr>
							<td colspan="2">
							<h3>Status: </h3><?php echo $sms_message['missingstatus']; ?>
						
						</td>
						</tr>
					
					<?php } ?>
					
					<?php if($sms_message['street'] != '' || $sms_message['city'] != '' || $sms_message['state'] != '' ){ ?>
					
					<tr>
							<td colspan="2">
							<h3>Address: </h3>
							<?php if($sms_message['street'] != ''){echo $sms_message['street'] . "<br>";}?>
						    <?php if($sms_message['city'] != ''){echo $sms_message['city'] . "<br>";}?>
						    <?php if($sms_message['state'] != ''){echo $sms_message['state'];}?>
						</td>
						</tr>
					
					<?php } ?>
					
						<?php if($sms_message['loc'] != ''){ ?>
					
					<tr>
							<td colspan="2">
							<h3>Latitude + Longitude: </h3><?php echo $sms_message['loc']; ?>
						
						</td>
						</tr>
					
					<?php } ?>
					
						
					<?php if($sms_message['phone'] != ''){ ?>
					
					<tr>
							<td colspan="2">
							<h3>Phone Contact in Haiti: </h3><?php echo $sms_message['phone']; ?>
						
						</td>
						</tr>
					
					<?php } ?>
					
						
						
						
					<tr>
							<td colspan="2">
							<h3>Message Content: </h3><?php echo preg_replace("/\%\%\%/","<br>",$sms_message['original_text']); ?>
						
						</td>
						</tr>
						
						<?php if($sms_message['comment'] != ''){ ?>
					
					<tr>
							<td colspan="2">
							<h3>Notes: </h3><?php echo $sms_message['comment']; ?>
						
						</td>
						</tr>
					
					<?php } ?>
					
						
						
					
					<!--
						<tr>		<td colspan="2">
							<h3>Url of Original Record: </h3><?php echo $sms_message['url']; ?>
							
						</td>
						</tr>-->
					
					<tr>
							<td colspan="2">
							<h3>Original Posting Date: </h3>&nbsp;<?php echo preg_replace("/\d\d:\d\d:\d\d/","",$sms_message['date_retrieved']); ?>
						
						</td>
							
						</tr>
						
							<tr>
							<td colspan="2">
							<h3>Original Site Name: </h3>4636
						
						</td>
					</tr>
					


                <?php  }  ?>

					<tr>
			<td colspan="2">
<br><br><br>
<input type="radio" name=update value="2">I Entered This Into Google<br>
<input type="radio" name=update value="3">This Person Was Already In Google<br>
<input type="radio" name=update value="4" >Not Enough Info - Take it out of the Queue<br>
<input type="radio" name=update value="0" checked>Put it Back in the Queue for Someone Else<br>

<td>
</tr>
<tr>
					<td colspan="2"><input type="submit" value="Submit" /><br></td>
				</tr>
				
				
					
				<?php 
				}else{
				?>
					<tr>
						<td colspan="2"><h3>The data queue is empty or there are no more messages in your language.</h3>&nbsp;</td>
					</tr>
				<?php
				}
				}
				?>
			
				<!--
				<tr>
					<td><label for="actionable">Actionable</label></td>
					<td><input type="checkbox" id="actionable" name="actionable" value="1" /></td>
				</tr>
				-->
				
					
			
			</table>
			</form>
			</div>
			</div>
			<div style="display:inline;float:right;width:500px;background-color:#fff;">
			
			<iframe
    src="http://haiticrisis.appspot.com"
    width=800px height=1000px frameborder=0
    style="border: dashed 2px #77c"></iframe>
    
    </div>
    <div style="clear:both;"></div>
			
	</div>
</div>
<?php require_once('footer.php'); ?>
</body>
</html>